package com.mybatis.jpa.sqlbuilder.insert;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

public class JavaTypeCollections {
	
	private static final Set<String> NUMBER_TYPE = new HashSet<>();
	private static final Set<String> NUMBER_BASIC_TYPE = new HashSet<>();
	private static final Set<String> DATE_TYPE = new HashSet<>();
	
	private static final String STRING_TYPE = String.class.getName();

	static {
		NUMBER_TYPE.add(Integer.class.getName());
		NUMBER_TYPE.add(Long.class.getName());
		NUMBER_TYPE.add(Double.class.getName());
		NUMBER_TYPE.add(Byte.class.getName());
		
		NUMBER_BASIC_TYPE.add("int");
		NUMBER_BASIC_TYPE.add("long");
		NUMBER_BASIC_TYPE.add("double");
		NUMBER_BASIC_TYPE.add("byte");
		
		DATE_TYPE.add(Date.class.getName());
		DATE_TYPE.add(Timestamp.class.getName());
	}
	
	private JavaTypeCollections(){}
	
	public static boolean isNumberType(String typeName) {
		return NUMBER_TYPE.contains(typeName);
	}
	
	public static boolean isNumberBasicType(String typeName) {
		return NUMBER_BASIC_TYPE.contains(typeName);
	}
	
	public static boolean isStringType(String typeName) {
		return StringUtils.equalsIgnoreCase(typeName, STRING_TYPE);
	}
	
	public static final boolean isDateType(String typeName) {
		return DATE_TYPE.contains(typeName);
	}
}
